import React, { Component } from 'react';
import '../../styles/homelist.scss'
import { Tag } from 'antd-mobile'
import {withRouter} from 'react-router-dom'
class HomeList extends Component {
    constructor(props) {
        super(props);
        this.state = {} //定义组件状态
    }
    toDetails = (goodid) => {
        this.props.history.push({pathname:'/details',state:{goodid}})
    }
    render() {
        return (
            <div className='homelist'>
                {
                    // 列表渲染, 使用js中的map函数
                    this.props.arr.map((item, index) => {
                        // console.log(this.props.arr);
                        return (
                            <div className="cart" key={index} onClick={()=>{this.toDetails(item.id)}}>
                                <img  src={item.pic} alt="" />
                                <h3>
                                    <Tag color='#ff6430' fill='outline'>{item.activityTags}</Tag>
                                    {item.name}
                                </h3>
                                <span>{item.salesPrice.name}</span>
                                <span>{item.salesPrice.value}</span>
                                   
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default withRouter(HomeList);